package xyz.hubery.mapper;

import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PathVariable;
import xyz.hubery.domain.EntrustOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.math.BigDecimal;

/**
 * @author huber
 * @description 针对表【entrust_order(委托订单信息)】的数据库操作Mapper
 * @createDate 2025-10-16 07:45:08
 * @Entity xyz.hubery.domain.EntrustOrder
 */
public interface EntrustOrderMapper extends BaseMapper<EntrustOrder> {

    /**
     * 根据id查询一条委托记录（同时加上行锁
     *
     * @param id
     * @return
     */
    EntrustOrder selectForUpdate(Long id);

    /**
     * 更新订单状态
     *
     * @param id     订单id
     * @param status 订单状态
     * @return
     */
    int updateStatus(@Param("id") long id, @Param("status") int status);


    /**
     * 乐观锁更新委托单
     * @param id
     * @param newFilledVolume
     * @param newStatus
     * @param oldVersion
     * @return
     */
    int updateOrderWithVersion
            (
                    @Param("id") Long id,
                    @Param("newFilledVolume") BigDecimal newFilledVolume,
                    @Param("newStatus") Integer newStatus,
                    @Param("oldVersion") Integer oldVersion
            );
}




